package com.neusoft.aclome.cmp.cloud.server.jcce.controller;

import com.neusoft.aclome.cmp.cloud.server.jcce.dto.request.JcceJobRequestDTO;
import com.neusoft.aclome.cmp.cloud.server.jcce.dto.response.JcceJobDTO;
import com.neusoft.aclome.cmp.cloud.server.jcce.service.JcceJobService;
import com.neusoft.aclome.cmp.cloud.server.pub.cloud.constants.PubApi;
import com.neusoft.aclome.cmp.common.model.vo.HttpResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * describe :
 *
 * @author hao.dd
 * @date 2023/11/6
 */
@Api("JcceJobController")
@RequestMapping("/jcce" + PubApi.VERSION + "/job")
@RestController
public class JcceJobController {

    @Value("${secret.privateKey}")
    private String key;

    @Autowired
    private JcceJobService jcceJobService;

    @GetMapping("list")
    @ApiOperation(value = "[课题4]查询job列表", notes = "listJcceJob")
    public HttpResponse listJcceJob(JcceJobRequestDTO request) {
        return HttpResponse.resultSuccess(jcceJobService.findJobsByCondition(request.getJobName(),
                request.getJobType(),
                request.getCloudPlatformId(),
                request.getStatus(),
                request.getPageNumber(),
                request.getPageSize(),
                request.getArriveStartTime(),
                request.getArriveEndTime()));
    }

    @PostMapping("create")
    @ApiOperation(value = "[课题4]创建job", notes = "jobcreateJcceJob")
    public HttpResponse createJcceJob(@ApiParam(value = "程序包,目前支持.tar.gz结尾的压缩包", required = false) MultipartFile files, JcceJobDTO dto) {
        return HttpResponse.resultSuccess(jcceJobService.createJcceJob(files, dto));
    }

}
